import React, { PureComponent } from 'react';
import { Affix } from 'antd';

export  default  class PateoAffix extends PureComponent<any,any>{

    state = {
        height: undefined // 浏览器可视化窗口高度
    };
    componentDidMount(): void {
        window.addEventListener('resize', this.handleResize); //监听窗口大小改变
        this.setState({ height: window.innerHeight })
    }
    componentWillUnmount(): void {
        window.removeEventListener('resize', this.handleResize)
    }
    handleResize = (e) =>{
       this.setState({ height: e.target.innerHeight })
    };

    render(){
        // scale 触发固钉高度百分比
       const { children, scale = 0.8 } = this.props;
       const { height } = this.state;
       return (
           <Affix offsetTop={height*scale} style={{ float:"right"}}>
               {
                   children
               }
           </Affix>
       );
   };
}



